

function say() {
    alert("82. 删除排序链表中的重复元素 II");
}
say();


/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var deleteDuplicates = function (head) {

    var dic = {}
    var move = head
    while(move){
        if(!dic[move.val]) {
            dic[move.val] = 0
        }
        dic[move.val]++
        move = move.next
    }

    var dumy = new ListNode(200)
    dumy.next = head
    var lastMove = head
    var pre = dumy
    while(lastMove){
        if(dic[lastMove.val] > 1){
            pre.next = lastMove.next //删除
            lastMove = lastMove.next //移动
        }else { //数量为1
            lastMove = lastMove.next
            pre = pre.next
        }
    }

    return dumy.next
};
